package com.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.utils.ScreenUtil;
import com.example.apple.ddhr_new.utils.ToastUtil;
import com.example.lzbase.BaseActivity;

import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;

public class EditActivity extends BaseActivity {


    @BindView(R.id.et_text)
    EditText etText;

    @Override
    protected int titleText() {
        return R.string.app_name;
    }

    @Override
    protected void created(@Nullable Bundle savedInstanceState) {


        setTitleRight(getString(R.string.baocun));

        setTitleText(getIntent().getExtras().getString("title"));
        etText.setHint(getIntent().getExtras().getString("hint"));
        etText.setText(getIntent().getExtras().getString("content"));

        if(getIntent().getExtras().getString("type").equals("1")){
          LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) etText.getLayoutParams();
          layoutParams.height = ScreenUtil.dp2px(this,280);
          etText.setLayoutParams(layoutParams);
        }
        if(getIntent().getExtras().getString("type").equals("8")){

            etText.setInputType(InputType.TYPE_CLASS_PHONE);
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_edit;
    }

    @Override
    protected void titleRightClick() {

        if(etText.getText().toString().trim().length()==0){
            ToastUtil.toast(this,etText.getHint().toString());
            return;
        }

        Intent intent = new Intent();
        intent.putExtra("data", etText.getText().toString());
        intent.putExtra("type", getIntent().getExtras().getString("type"));
        setResult(1000, intent);
        finish();
    }


}
